home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / tk / ParseArgv.man < prev    next >
Encoding:
Text File  |  1992-08-24  |  17.9 KB  |  529 lines

  1. '\"
  2. '\" Copyright 1990-1992 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/wish/man/RCS/ParseArgv.man,v 1.5 92/05/07 09:08:05 ouster Exp $ SPRITE (Berkeley)
  11. '\" 
  12. .\" The definitions below are for supplemental macros used in Sprite
  13. .\" manual entries.
  14. .\"
  15. .\" .HS name section [date [version]]
  16. .\"    Replacement for .TH in other man pages.  See below for valid
  17. .\"    section names.
  18. .\"
  19. .\" .AP type name in/out [indent]
  20. .\"    Start paragraph describing an argument to a library procedure.
  21. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  22. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  23. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  24. .\"    needed;  use .AS below instead)
  25. .\"
  26. .\" .AS [type [name]]
  27. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  28. .\"    name are examples of largest possible arguments that will be passed
  29. .\"    to .AP later.  If args are omitted, default tab stops are used.
  30. .\"
  31. .\" .BS
  32. .\"    Start box enclosure.  From here until next .BE, everything will be
  33. .\"    enclosed in one large box.
  34. .\"
  35. .\" .BE
  36. .\"    End of box enclosure.
  37. .\"
  38. .\" .VS
  39. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  40. .\"    of man pages.
  41. .\"
  42. .\" .VE
  43. .\"    End of vertical sidebar.
  44. .\"
  45. .\" .DS
  46. .\"    Begin an indented unfilled display.
  47. .\"
  48. .\" .DE
  49. .\"    End of indented unfilled display.
  50. .\"
  51. '\"    # Heading for Sprite man pages
  52. .de HS
  53. .if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  54. .if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  55. .if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  56. .if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  57. .if t .wh -1.3i ^B
  58. .nr ^l \\n(.l
  59. .ad b
  60. ..
  61. '\"    # Start an argument description
  62. .de AP
  63. .ie !"\\$4"" .TP \\$4
  64. .el \{\
  65. .   ie !"\\$2"" .TP \\n()Cu
  66. .   el          .TP 15
  67. .\}
  68. .ie !"\\$3"" \{\
  69. .ta \\n()Au \\n()Bu
  70. \&\\$1    \\fI\\$2\\fP    (\\$3)
  71. .\".b
  72. .\}
  73. .el \{\
  74. .br
  75. .ie !"\\$2"" \{\
  76. \&\\$1    \\fI\\$2\\fP
  77. .\}
  78. .el \{\
  79. \&\\fI\\$1\\fP
  80. .\}
  81. .\}
  82. ..
  83. '\"    # define tabbing values for .AP
  84. .de AS
  85. .nr )A 10n
  86. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  87. .nr )B \\n()Au+15n
  88. .\"
  89. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  90. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  91. ..
  92. '\"    # BS - start boxed text
  93. '\"    # ^y = starting y location
  94. '\"    # ^b = 1
  95. .de BS
  96. .br
  97. .mk ^y
  98. .nr ^b 1u
  99. .if n .nf
  100. .if n .ti 0
  101. .if n \l'\\n(.lu\(ul'
  102. .if n .fi
  103. ..
  104. '\"    # BE - end boxed text (draw box now)
  105. .de BE
  106. .nf
  107. .ti 0
  108. .mk ^t
  109. .ie n \l'\\n(^lu\(ul'
  110. .el \{\
  111. .\"    Draw four-sided box normally, but don't draw top of
  112. .\"    box if the box started on an earlier page.
  113. .ie !\\n(^b-1 \{\
  114. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  115. .\}
  116. .el \}\
  117. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  118. .\}
  119. .\}
  120. .fi
  121. .br
  122. .nr ^b 0
  123. ..
  124. '\"    # VS - start vertical sidebar
  125. '\"    # ^Y = starting y location
  126. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  127. .de VS
  128. .mk ^Y
  129. .ie n 'mc \s12\(br\s0
  130. .el .nr ^v 1u
  131. ..
  132. '\"    # VE - end of vertical sidebar
  133. .de VE
  134. .ie n 'mc
  135. .el \{\
  136. .ev 2
  137. .nf
  138. .ti 0
  139. .mk ^t
  140. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  141. .sp -1
  142. .fi
  143. .ev
  144. .\}
  145. .nr ^v 0
  146. ..
  147. '\"    # Special macro to handle page bottom:  finish off current
  148. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  149. '\"    # page bottom macro.
  150. .de ^B
  151. .ev 2
  152. 'ti 0
  153. 'nf
  154. .mk ^t
  155. .if \\n(^b \{\
  156. .\"    Draw three-sided box if this is the box's first page,
  157. .\"    draw two sides but no top otherwise.
  158. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  159. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  160. .\}
  161. .if \\n(^v \{\
  162. .nr ^x \\n(^tu+1v-\\n(^Yu
  163. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  164. .\}
  165. .bp
  166. 'fi
  167. .ev
  168. .if \\n(^b \{\
  169. .mk ^y
  170. .nr ^b 2
  171. .\}
  172. .if \\n(^v \{\
  173. .mk ^Y
  174. .\}
  175. ..
  176. '\"    # DS - begin display
  177. .de DS
  178. .RS
  179. .nf
  180. .sp
  181. ..
  182. '\"    # DE - end display
  183. .de DE
  184. .fi
  185. .RE
  186. .sp .5
  187. ..
  188. .HS Tk_ParseArgv tk
  189. .BS
  190. .SH NAME
  191. Tk_ParseArgv \- process command-line options
  192. .SH SYNOPSIS
  193. \fB#include <tk.h>\fR
  194. .sp
  195. int
  196. .br
  197. \fBTk_ParseArgv\fR(\fIinterp, tkwin, argcPtr, argv, argTable, flags\fR)
  198. .SH ARGUMENTS
  199. .AS Tk_ArgvInfo *argTable
  200. .AP Tcl_Interp *interp in
  201. Interpreter to use for returning error messages.
  202. .AP Tk_Window tkwin in
  203. Window to use when arguments specify Tk options.  If NULL, then
  204. no Tk options will be processed.
  205. .AP int argcPtr in/out
  206. Pointer to number of arguments in argv;  gets modified to hold
  207. number of unprocessed arguments that remain after the call.
  208. .AP char **argv in/out
  209. Command line arguments passed to main program.  Modified to
  210. hold unprocessed arguments that remain after the call.
  211. .AP Tk_ArgvInfo *argTable in
  212. Array of argument descriptors, terminated by element with
  213. type TK_ARGV_END.
  214. .AP int flags in
  215. If non-zero, then it specifies one or more flags that control the
  216. parsing of arguments.  Different flags may be OR'ed together.
  217. .na
  218. The flags currently defined are TK_ARGV_DONT_SKIP_FIRST_ARG,
  219. TK_ARGV_NO_ABBREV, TK_ARGV_NO_LEFTOVERS, and TK_ARGV_NO_DEFAULTS.
  220. .ad
  221. .BE
  222. .SH DESCRIPTION
  223. .PP
  224. \fBTk_ParseArgv\fR processes an array of command-line arguments according
  225. to a table describing the kinds of arguments that are expected.
  226. Each of the arguments in \fIargv\fR is processed in turn:  if it matches
  227. one of the entries in \fIargTable\fR, the argument is processed
  228. according to that entry and discarded.  The arguments that do not
  229. match anything in \fIargTable\fR are copied down to the beginning
  230. of \fIargv\fR (retaining their original order) and returned to
  231. the caller.  At the end of the call
  232. \fBTk_ParseArgv\fR sets \fI*argcPtr\fR to hold the number of
  233. arguments that are left in \fIargv\fR, and \fIargv[*argcPtr]\fR
  234. will hold the value NULL.  Normally, \fBTk_ParseArgv\fR
  235. assumes that \fIargv[0]\fR is a command name, so it is treated like
  236. an argument that doesn't match \fIargTable\fR and returned to the
  237. caller;  however, if the TK_ARGV_DONT_SKIP_FIRST_ARG bit is set in
  238. \fIflags\fR then \fIargv[0]\fR will be processed just like the other
  239. elements of \fIargv\fR.
  240. .PP
  241. \fBTk_ParseArgv\fR normally returns the value TCL_OK.  If an error
  242. occurs while parsing the arguments, then TCL_ERROR is returned and
  243. \fBTk_ParseArgv\fR will leave an error message in \fIinterp->result\fR
  244. in the standard Tcl fashion.  In
  245. the event of an error return, \fI*argvPtr\fR will not have been
  246. modified, but \fIargv\fR could have been partially modified.  The
  247. possible causes of errors are explained below.
  248. .PP
  249. The \fIargTable\fR array specifies the kinds of arguments that are
  250. expected;  each of its entries has the following structure:
  251. .DS
  252. .ta 2c
  253. \fBtypedef struct\fR {
  254.     \fBchar\fR    *\fIkey\fR;
  255.     \fBint\fR    \fItype\fR;
  256.     \fBchar\fR    *\fIsrc\fR;
  257.     \fBchar\fR    *\fIdst\fR;
  258.     \fBchar\fR    *\fIhelp\fR;
  259. \fB} Tk_ArgvInfo;\fR
  260. .DE
  261. .LP
  262. The \fIkey\fR field is a string such as ``\-display'' or ``\-bg''
  263. that is compared with the values in \fIargv\fR.  \fIType\fR
  264. indicates how to process an argument that matches \fIkey\fR
  265. (more on this below).  \fISrc\fR and \fIdst\fR are additional
  266. values used in processing the argument.  Their exact usage
  267. depends on \fItype\fR, but typically \fIsrc\fR indicates
  268. a value and \fIdst\fR indicates where to store the
  269. value.  The \fBchar *\fR declarations for \fIsrc\fR and \fIdst\fR
  270. are placeholders:  the actual types may be different.  Lastly,
  271. \fIhelp\fR is a string giving a brief description
  272. of this option;  this string is printed when users ask for help
  273. about command-line options.
  274. .PP
  275. When processing an argument in \fIargv\fR, \fBTk_ParseArgv\fR
  276. compares the argument to each of the \fIkey\fR's in \fIargTable\fR.
  277. \fBTk_ParseArgv\fR selects the first specifier whose \fIkey\fR matches
  278. the argument exactly, if such a specifier exists.  Otherwise
  279. \fBTk_ParseArgv\fR selects a specifier for which the argument
  280. is a unique abbreviation.  If the argument is a unique abbreviation
  281. for more than one specifier, then an error is returned.  If there
  282. is no matching entry in \fIargTable\fR, then the argument is
  283. skipped and returned to the caller.
  284. .PP
  285. Once a matching argument specifier is found, \fBTk_ParseArgv\fR
  286. processes the argument according to the \fItype\fR field of the
  287. specifier.  The argument that matched \fIkey\fR is called ``the matching
  288. argument'' in the descriptions below.  As part of the processing,
  289. \fBTk_ParseArgv\fR may also use the next argument in \fIargv\fR
  290. after the matching argument, which is called ``the following
  291. argument''.  The legal values for \fItype\fR, and the processing
  292. that they cause, are as follows:
  293. .TP
  294. \fBTK_ARGV_END\fR
  295. Marks the end of the table.  The last entry in \fIargTable\fR
  296. must have this type;  all of its other fields are ignored and it
  297. will never match any arguments.
  298. .TP
  299. \fBTK_ARGV_CONSTANT\fR
  300. \fISrc\fR is treated as an integer and \fIdst\fR is treated
  301. as a pointer to an integer.  \fISrc\fR is stored at \fI*dst\fR.
  302. The matching argument is discarded.
  303. .TP
  304. \fBTK_ARGV_INT\fR
  305. The following argument must contain an
  306. integer string in the format accepted by \fBstrtol\fR (e.g. ``0''
  307. and ``0x'' prefixes may be used to specify octal or hexadecimal
  308. numbers, respectively).  \fIDst\fR is treated as a pointer to an
  309. integer;  the following argument is converted to an integer value
  310. and stored at \fI*dst\fR.  \fISrc\fR is ignored.  The matching
  311. and following arguments are discarded from \fIargv\fR.
  312. .TP
  313. \fBTK_ARGV_FLOAT\fR
  314. The following argument must contain a floating-point number in
  315. the format accepted by \fBstrtol\fR.
  316. \fIDst\fR is treated as the address of an double-precision
  317. floating point value;  the following argument is converted to a
  318. double-precision value and stored at \fI*dst\fR.  The matching
  319. and following arguments are discarded from \fIargv\fR.
  320. .TP
  321. \fBTK_ARGV_STRING\fR
  322. In this form, \fIdst\fR is treated as a pointer to a (char *);
  323. \fBTk_ParseArgv\fR stores at \fI*dst\fR a pointer to the following
  324. argument, and discards the matching and following arguments from
  325. \fIargv\fR.  \fISrc\fR is ignored.
  326. .TP
  327. \fBTK_ARGV_UID\fR
  328. This form is similar to TK_ARGV_STRING, except that the argument
  329. is turned into a Tk_Uid by calling \fBTk_GetUid\fR.
  330. \fIDst\fR is treated as a pointer to a
  331. Tk_Uid; \fBTk_ParseArgv\fR stores at \fI*dst\fR the Tk_Uid
  332. corresponding to the following
  333. argument, and discards the matching and following arguments from
  334. \fIargv\fR.  \fISrc\fR is ignored.
  335. .TP
  336. \fBTK_ARGV_CONST_OPTION\fR
  337. This form causes a Tk option to be set (as if the \fBoption\fR
  338. command had been invoked).  The \fIsrc\fR field is treated as a
  339. pointer to a string giving the value of an option, and \fIdst\fR
  340. is treated as a pointer to the name of the option.  The matching
  341. argument is discarded.  If \fItkwin\fR is NULL, then argument
  342. specifiers of this type are ignored (as if they did not exist).
  343. .TP
  344. \fBTK_ARGV_OPTION_VALUE\fR
  345. This form is similar to TK_ARGV_CONST_OPTION, except that the
  346. value of the option is taken from the following argument instead
  347. of from \fIsrc\fR.  \fIDst\fR is used as the name of the option.
  348. \fISrc\fR is ignored.  The matching and following arguments
  349. are discarded.  If \fItkwin\fR is NULL, then argument
  350. specifiers of this type are ignored (as if they did not exist).
  351. .TP
  352. \fBTK_ARGV_OPTION_NAME_VALUE\fR
  353. In this case the following argument is taken as the name of a Tk
  354. option and the argument after that is taken as the value for that
  355. option.  Both \fIsrc\fR and \fIdst\fR are ignored.  All three
  356. arguments are discarded from \fIargv\fR.  If \fItkwin\fR is NULL,
  357. then argument
  358. specifiers of this type are ignored (as if they did not exist).
  359. .TP
  360. \fBTK_ARGV_HELP\fR
  361. When this kind of option is encountered, \fBTk_ParseArgv\fR uses the
  362. \fIhelp\fR fields of \fIargTable\fR to format a message describing
  363. all the valid arguments.  The message is placed in \fIinterp->result\fR
  364. and \fBTk_ParseArgv\fR returns TCL_ERROR.  When this happens, the
  365. caller normally prints the help message and aborts.  If the \fIkey\fR
  366. field of a TK_ARGV_HELP specifier is NULL, then the specifier will
  367. never match any arguments;  in this case the specifier simply provides
  368. extra documentation, which will be included when some other
  369. TK_ARGV_HELP entry causes help information to be returned.
  370. .TP
  371. \fBTK_ARGV_REST\fR
  372. This option is used by programs or commands that allow the last
  373. several of their options to be the name and/or options for some
  374. other program.  If a \fBTK_ARGV_REST\fR argument is found, then
  375. \fBTk_ParseArgv\fR doesn't process any
  376. of the remaining arguments;  it returns them all at
  377. the beginning of \fIargv\fR (along with any other unprocessed arguments).
  378. In addition, \fBTk_ParseArgv\fR treats \fIdst\fR as the address of an
  379. integer value, and stores at \fI*dst\fR the index of the first of the
  380. \fBTK_ARGV_REST\fR options in the returned \fIargv\fR.  This allows the
  381. program to distinguish the \fBTK_ARGV_REST\fR options from other
  382. unprocessed options that preceeded the \fBTK_ARGV_REST\fR.
  383. .TP
  384. \fBTK_ARGV_FUNC\fR
  385. For this kind of argument, \fIsrc\fR is treated as the address of
  386. a procedure, which is invoked to process the following argument.
  387. The procedure should have the following structure:
  388. .DS
  389. .ta 1c 2c 3c 4c 5c 6c
  390. \fBint\fI
  391. func(dst, key, nextArg)
  392.     \fBchar\fR    *\fIdst\fR;
  393.     \fBchar\fR    *\fIkey\fR;
  394.     \fBchar\fR    *\fInextArg\fR;
  395. {
  396. }
  397. .DE
  398. .IP
  399. The \fIdst\fR and \fIkey\fR parameters will contain the
  400. corresponding fields from the \fIargTable\fR entry, and
  401. \fInextArg\fR will point to the following argument from \fIargv\fR
  402. (or NULL if there aren't any more arguments left in \fIargv\fR).
  403. If \fIfunc\fR uses \fInextArg\fR (so that
  404. \fBTk_ParseArgv\fR should discard it), then it should return 1.  Otherwise it
  405. should return 0 and \fBTkParseArgv\fR will process the following
  406. argument in the normal fashion.  In either event the matching argument
  407. is discarded.
  408. .TP
  409. \fBTK_ARGV_GENFUNC\fR
  410. This form provides a more general procedural escape.  It treats
  411. \fIsrc\fR as the address of a procedure, and passes that procedure
  412. all of the remaining arguments.  The procedure should have the following
  413. form:
  414. .DS
  415. .ta 1c 2c 3c 4c 5c 6c
  416. \fBint\fI
  417. genfunc(dst, interp, key, argc, argv)
  418.     \fBchar\fR    *\fIdst\fR;
  419.     \fBTcl_Interp\fR    *\fIinterp\fR;
  420.     \fBchar\fR    *\fIkey\fR;
  421.     \fBint\fR    \fIargc\fR;
  422.     \fBchar\fR    **\fIargv\fR;
  423. {
  424. }
  425. .DE
  426. .IP
  427. The \fIdst\fR and \fIkey\fR parameters will contain the
  428. corresponding fields from the \fIargTable\fR entry.  \fIInterp\fR
  429. will be the same as the \fIinterp\fR argument to \fBTcl_ParseArgv\fR.
  430. \fIArgc\fR and \fIargv\fR refer to all of the options after the
  431. matching one.  \fIGenfunc\fR should behave in a fashion similar
  432. to \fBTk_ParseArgv\fR:  parse as many of the remaining arguments as it can,
  433. then return any that are left by compacting them to the beginning of
  434. \fIargv\fR (starting at \fIargv\fR[0]).  \fIGenfunc\fR
  435. should return a count of how many arguments are left in \fIargv\fR;
  436. \fBTk_ParseArgv\fR will process them.  If \fIgenfunc\fR encounters
  437. an error then it should leave an error message in \fIinterp->result\fR,
  438. in the usual Tcl fashion, and return -1;  when this happens
  439. \fBTk_ParseArgv\fR will abort its processing and return TCL_ERROR.
  440.  
  441. .SH "FLAGS"
  442. .IP \fBTK_ARGV_DONT_SKIP_FIRST_ARG\fR
  443. \fBTk_ParseArgv\fR normally treats \fIargv[0]\fR as a program
  444. or command name, and returns it to the caller just as if it
  445. hadn't matched \fIargTable\fR.  If this flag is given, then
  446. \fIargv[0]\fR is not given special treatment.
  447. .IP \fBTK_ARGV_NO_ABBREV\fR
  448. Normally, \fBTk_ParseArgv\fR accepts unique abbreviations for
  449. \fIkey\fR values in \fIargTable\fR.  If this flag is given then
  450. only exact matches will be acceptable.
  451. .IP \fBTK_ARGV_NO_LEFTOVERS\fR
  452. Normally, \fBTk_ParseArgv\fR returns unrecognized arguments to the
  453. caller.  If this bit is set in \fIflags\fR then \fBTk_ParseArgv\fR
  454. will return an error if it encounters any argument that doesn't
  455. match \fIargTable\fR.  The only exception to this rule is \fIargv[0]\fR,
  456. which will be returned to the caller with no errors as
  457. long as TK_ARGV_DONT_SKIP_FIRST_ARG isn't specified.
  458. .IP \fBTK__NO_DEFAULTS\fR
  459. Normally, \fBTk_ParseArgv\fR searches an internal table of
  460. standard argument specifiers in addition to \fIargTable\fR.  If
  461. this bit is set in \fIflags\fR, then \fBTk_ParseArgv\fR will
  462. use only \fIargTable\fR and not its default table.
  463.  
  464. .SH EXAMPLE
  465. .PP
  466. Here is an example definition of an \fIargTable\fR and
  467. some sample command lines that use the options.  Note the effect
  468. on \fIargc\fR and \fIargv\fR;  arguments processed by \fBTk_ParseArgv\fR
  469. are eliminated from \fIargv\fR, and \fIargc\fR
  470. is updated to reflect reduced number of arguments.
  471. .DS L
  472. \fC/*
  473.  * Define and set default values for globals.
  474.  */
  475. int debugFlag = 0;
  476. int numReps = 100;
  477. char defaultFileName[] = "out";
  478. char *fileName = defaultFileName;
  479. Boolean exec = FALSE;
  480.  
  481. /*
  482.  * Define option descriptions.
  483.  */
  484. Tk_ArgvInfo argTable[] = {
  485.     {"-X", TK_ARGV_CONSTANT, (char *) 1, (char *) &debugFlag,
  486.         "Turn on debugging printfs"},
  487.     {"-N", TK_ARGV_INT, (char *) NULL, (char *) &numReps,
  488.         "Number of repetitions"},
  489.     {"-of", TK_ARGV_STRING, (char *) NULL, (char *) &fileName,
  490.         "Name of file for output"},
  491.     {"x", TK_ARGV_REST, (char *) NULL, (char *) &exec,
  492.         "File to exec, followed by any arguments (must be last argument)."},
  493.     {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
  494.         (char *) NULL}
  495. };
  496.  
  497. main(argc, argv)
  498.     int argc;
  499.     char *argv[];
  500. {
  501.     \&...
  502.  
  503.     if (Tk_ParseArgv(interp, tkwin, &argc, argv, argTable, 0) != TCL_OK) {
  504.         fprintf(stderr, "%s\en", interp->result);
  505.         exit(1);
  506.     }
  507.  
  508.     /*
  509.      * Remainder of the program.
  510.      */
  511. }\fR
  512. .DE
  513. .PP
  514. Note that default values can be assigned to variables named in
  515. \fIargTable\fR:  the variables will only be overwritten if the
  516. particular arguments are present in \fIargv\fR.
  517. Here are some example command lines and their effects.
  518. .DS
  519. \fCprog -N 200 infile        # just sets the numReps variable to 200
  520. prog -of out200 infile     # sets fileName to reference "out200"
  521. prog -XN 10 infile        # sets the debug flag, also sets numReps\fR
  522. .DE
  523. In all of the above examples, \fIargc\fR will be set by \fBTk_ParseArgv\fR to 2,
  524. \fIargv\fR[0] will be ``prog'', \fIargv\fR[1] will be ``infile'',
  525. and \fIargv\fR[2] will be NULL.
  526.  
  527. .SH KEYWORDS
  528. arguments, command line, options
  529.